package backend;

import frontend.BoardFrame;

public class GodMode {


	//VARIALBLE/S
	int mode;
	private BoardFrame boardFrame;
	int modifyDice;
	
	public GodMode(BoardFrame boardFrame) {
		this.mode=3;
		this.boardFrame = boardFrame;
	}
	
	//GETTERS
	public int getMode() {
		return this.mode;
	}
	public BoardFrame getBoardFrame() {
		return this.boardFrame;
	}
	public int getModifyDice() {
		return this.modifyDice;
	}


	//SETTERS
	public void setMode(int mode) {
		this.mode = mode;
	}
	public void setBoardFrame(BoardFrame boardFrame) {
		this.boardFrame = boardFrame;
	}
	public void setModifyDice(int modifyDice) {
		this.modifyDice = modifyDice;
	}


	//OTHER METHODS
	public void resetMode() {
		this.mode = 0;
	}
	
	public void resetDiceMode() {
		
	}

	public void selectMode() {
		switch(this.mode) {
				case 0://Dice Always Doubles
					break;
				case 1://Dice Never Doubles
					break;
		       	case 2://Set Dice Value
		       		this.modifyDiceValue();
		       		break;
		       	case 3://Set Dice Normal
		       		break;
		       	case 4://Utility Property
		       		this.testUtility();
		       		break;
		       	case 5://Station Property
		       		this.testStation();
		       		break;
		       	case 6://Estate Property
		       		this.testEstate();
		       		break;
		       	case 7://Chance Cards
		       		this.testChanceCard();
		       		break;
		       	case 8://Community Chest
		       		this.testCommunityChest();
		       		break;
		       	case 9://Taxes
		       		this.testTaxes();
		       		break;
		       	case 10://Go to Jail
		       		this.testGoToJail();
		       		break;
		       	default:
		       		break;
		}
	}

	public void setupCounterStep() {
		//Set current player's token counter & step direction
		this.boardFrame.setCtr(0);
		this.boardFrame.setStep(1);
	}
	
	public void modifyDiceValue() {
		this.boardFrame.setDestination(this.modifyDice);
		this.setupCounterStep();
	}
	
	//Test Community Chest Function
	void testCommunityChest() {
		//Set current player's token destination
		if(2>this.boardFrame.getCurrentPlayer().getToken().getPosition()) {
			this.boardFrame.setDestination(2 - this.boardFrame.getCurrentPlayer().getToken().getPosition());
		}
		else {
			if(17>this.boardFrame.getCurrentPlayer().getToken().getPosition()) {
				this.boardFrame.setDestination(17 - this.boardFrame.getCurrentPlayer().getToken().getPosition());
			}
			else {
				if(33>this.boardFrame.getCurrentPlayer().getToken().getPosition()) {
					this.boardFrame.setDestination(33 - this.boardFrame.getCurrentPlayer().getToken().getPosition());
				}
				else {
					this.boardFrame.setDestination(42 - this.boardFrame.getCurrentPlayer().getToken().getPosition());
				}
			}
		}
		this.setupCounterStep();
	}
	
	//Test Chance Card Function
	public void testChanceCard() {
		//Set current player's token destination
		if(7>this.boardFrame.getCurrentPlayer().getToken().getPosition()) {
			this.boardFrame.setDestination(7 - this.boardFrame.getCurrentPlayer().getToken().getPosition());
		}
		else {
			if(22>this.boardFrame.getCurrentPlayer().getToken().getPosition()) {
				this.boardFrame.setDestination(22 - this.boardFrame.getCurrentPlayer().getToken().getPosition());
			}
			else {
				if(36>this.boardFrame.getCurrentPlayer().getToken().getPosition()) {
					this.boardFrame.setDestination(36 - this.boardFrame.getCurrentPlayer().getToken().getPosition());
				}
				else {
					this.boardFrame.setDestination(47 - this.boardFrame.getCurrentPlayer().getToken().getPosition());
				}
			}
		}
		this.setupCounterStep();
	}
	
	//Test Utility Property Tiles
	public void testUtility() {
		if(12>this.boardFrame.getCurrentPlayer().getToken().getPosition()) {
			this.boardFrame.setDestination(12 - this.boardFrame.getCurrentPlayer().getToken().getPosition());
		}
		else {
			if(28>this.boardFrame.getCurrentPlayer().getToken().getPosition()) {
				this.boardFrame.setDestination(28 - this.boardFrame.getCurrentPlayer().getToken().getPosition());
			}
			else {
				this.boardFrame.setDestination(52 - this.boardFrame.getCurrentPlayer().getToken().getPosition());
			}
		}
		this.setupCounterStep();
	}
	
	//Test Station Property Tiles
	public void testStation() {
		//Set current player's token destination
		if(5>this.boardFrame.getCurrentPlayer().getToken().getPosition()) {
			this.boardFrame.setDestination(5 - this.boardFrame.getCurrentPlayer().getToken().getPosition());
		}
		else {
			if(15>this.boardFrame.getCurrentPlayer().getToken().getPosition()) {
				this.boardFrame.setDestination(15 - this.boardFrame.getCurrentPlayer().getToken().getPosition());
			}
			else {
				if(25>this.boardFrame.getCurrentPlayer().getToken().getPosition()) {
					this.boardFrame.setDestination(25 - this.boardFrame.getCurrentPlayer().getToken().getPosition());
				}
				else {
					if(35>this.boardFrame.getCurrentPlayer().getToken().getPosition()) {
						this.boardFrame.setDestination(35 - this.boardFrame.getCurrentPlayer().getToken().getPosition());
					}
					else {
						this.boardFrame.setDestination(45 - this.boardFrame.getCurrentPlayer().getToken().getPosition());
					}
				}
			}
		}
		this.setupCounterStep();
	}
	
	//Test Estate Properties
	public void testEstate() {
		int position = this.boardFrame.getCurrentPlayer().getToken().getPosition();
		if(0==position) {
			this.boardFrame.setDestination(1);
		}
		if(1<=position && 3>position) {
			this.boardFrame.setDestination(3 - position);
		}
		if(3<=position && 6>position) {
			this.boardFrame.setDestination(6 - position);
		}
		if(6<=position && 8>position) {
			this.boardFrame.setDestination(8 - position);
		}
		if(8==position) {
			this.boardFrame.setDestination(1);
		}
		if(9<=position && 11>position) {
			this.boardFrame.setDestination(11 - position);
		}
		if(11<=position && 13>position) {
			this.boardFrame.setDestination(13 - position);
		}
		if(13==position) {
			this.boardFrame.setDestination(1);
		}
		if(14<=position && 16>position) {
			this.boardFrame.setDestination(16 - position);
		}
		if(16<=position && 18>position) {
			this.boardFrame.setDestination(18 - position);
		}
		if(18==position) {
			this.boardFrame.setDestination(1);
		}
		if(19<=position && 21>position) {
			this.boardFrame.setDestination(21 - position);
		}
		if(21<=position && 23>position) {
			this.boardFrame.setDestination(23 - position);
		}
		if(23==position) {
			this.boardFrame.setDestination(1);
		}
		if(24<=position && 26>position) {
			this.boardFrame.setDestination(26 - position);
		}
		if(26==position) {
			this.boardFrame.setDestination(1);
		}
		if(27<=position && 29>position) {
			this.boardFrame.setDestination(29 - position);
		}
		if(29<=position && 31>position) {
			this.boardFrame.setDestination(31 - position);
		}
		if(31==position) {
			this.boardFrame.setDestination(1);
		}
		if(32<=position && 34>position) {
			this.boardFrame.setDestination(34 - position);
		}
		if(34<=position && 37>position) {
			this.boardFrame.setDestination(37 - position);
		}
		if(37<=position && 39>position) {
			this.boardFrame.setDestination(39 - position);
		}
		this.setupCounterStep();
	}
	
	//Test Go to Jail Tile
	public void testGoToJail() {
		//Set current player's token destination
		if(30>this.boardFrame.getCurrentPlayer().getToken().getPosition()) {
			this.boardFrame.setDestination(30 - this.boardFrame.getCurrentPlayer().getToken().getPosition());
		}
		else {
				this.boardFrame.setDestination(70 - this.boardFrame.getCurrentPlayer().getToken().getPosition());
		}
		this.setupCounterStep();
	}
	
	//Test Tax Tiles Function
	public void testTaxes() {
		if(4>this.boardFrame.getCurrentPlayer().getToken().getPosition()) {
			this.boardFrame.setDestination(4 - this.boardFrame.getCurrentPlayer().getToken().getPosition());
		}
		else {
			if(38>this.boardFrame.getCurrentPlayer().getToken().getPosition()) {
				this.boardFrame.setDestination(38 - this.boardFrame.getCurrentPlayer().getToken().getPosition());
			}
			else {
				this.boardFrame.setDestination(44 - this.boardFrame.getCurrentPlayer().getToken().getPosition());
			}
		}
		this.setupCounterStep();
	}
}

